#!/bin/bash

# ----------------------------------------------------------------------
# Filename:   75643-mkdir.sh
# Version:    1.0
# Date:       2013/12/19
# Author:     yuanhui.shi
# Email:      yuanhui.shi@cs2c.com.cn
# Summary:    03系统安全功能-01SELinux-03SELinux重要命令-03SELinux安全上下文标签相关命令-07mkdir
# Notes:      安全上下文标签 mkdir
# Copyright:  China Standard Software Co., Ltd.
# History：     
#             Version 1.0, 2013/12/19
#             -   The first one
# ----------------------------------------------------------------------

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH

source ../../lib/Echo.sh
source ../../lib/XmlParse.sh
source ./lib/Selib.sh

function CleanData ()
{
  rm -rf /tmp/test 
  EchoInfo "75643-mkdir.sh执行完毕"
}

trap "CleanData" EXIT
CheckSElinuxStatus

mkdir /tmp/test

mkdir -Z system_u:object_r:httpd_config_t:s0 /tmp/test/dir1

[ "`ls -dZ /tmp/test/dir1 |awk '{print $4}'`" == "system_u:object_r:httpd_config_t:s0" ]
EchoResult "命令mkdir -Z执行结果正确"

rm -rf /tmp/test/dir1

mkdir --context system_u:object_r:user_tmp_t:s0 /tmp/test/dir2

[ "`ls -dZ /tmp/test/dir2 |cut -d ' ' -f4`" == "system_u:object_r:user_tmp_t:s0" ]
EchoResult "命令mkdir --context执行结果正确" 

